import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'

function _resolve(dir) {
  return path.resolve(__dirname, dir)
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
  ],
  build: {
    outDir: path.resolve(__dirname, 'dist'),
    assetsDir: 'assets',
    assetsInlineLimit: 8192,
    emptyOutDir: true,
    sourcemap: false,
    chunkSizeWarningLimit: 1500,
    rollupOptions: {
      input: path.resolve(__dirname, 'index.html'),
      output: {
        chunkFileNames: 'js/[name].[hash].js',
        entryFileNames: 'js/[name].[hash].js',
        // assetFileNames: "assets/[name].[hash].[ext]",
      }
    }
  },
  resolve: {
    alias: [
      {find: /^@\//, replacement: `${_resolve('src')}/`}
    ],
    extensions: ['.js', '.mjs', '.vue', '.json', '.less', '.css']
  },
  server: {
    host: "0.0.0.0",
    port: 8082,
    hmr: true,
    proxy: {
      // '/web': {
      //   // target: 'https://www.hzszaz.com/', // 接口的域名
      //   target: 'https://hz-test.us-smart.cn/', // 接口的域名
      //   secure: true, // 如果是https接口，需要配置这个参数
      //   changeOrigin: true, // 如果接口跨域，需要进行这个参数配置
      // }
    },
  },
})
